# Maintainer: Naveen M K <naveen521kk@gmail.com>

_pyname=tomli
_realname=tomli
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.2.1
pkgrel=1
pkgdesc="A lil' TOML parser (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://pypi.org/project/tomli/"
license=('MIT')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python" 
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build" 
  "${MINGW_PACKAGE_PREFIX}-python-flit-core"
  "${MINGW_PACKAGE_PREFIX}-python-pip"
)
source=("${_pyname}-${pkgver}.tar.gz::https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('a5b75cb6f3968abb47af1b40c1819dc519ea82bcc065776a866e8d74c5ca9442')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_pyname//_/-}-$pkgver" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python -m build . -x -n -w
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python -m pip install dist/${_pyname}-${pkgver}-py3-none-any.whl \
    --compile \
    --no-deps \
    --no-warn-script-location \
    --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}"

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
